const cheerio = require('cheerio');
// const { textToUrlEnCode } = require('./utils/common');
const { abc_search } = require('./handleDom/search');
const { abc_detail, qianbi_detail } = require('./handleDom/detail');
const { abc_bookText, qianbi_bookText } = require('./handleDom/bookText');
const { abc_classify, qianbi_classify } = require('./handleDom/classify');

const config = {
	yetian: {
		name: 'yetian',
		host: 'http://www.yetianlian.info/',
		charset: 'utf-8',
		// 搜索内容
		search: {
			host: (data) => `${config.yetian.host}s.php?ie=utf-8&q=${data.q}`,
			regExp: (html, source) => abc_search(html, source, config.yetian.host),
		},
		// 小说详情
		bookDetail: {
			host: (data) => `${config.yetian.host}${data.bookId}/`,
			regExp: (html, source) => abc_detail(html, source, config.yetian.host),
		},
		// 文本
		bookText: {
			host: (data) =>
				`${config.yetian.host}${data.bookId}/${data.chapterId}.html`,
			regExp: (html) => abc_bookText(html),
		},
		// 分类
		classify: {
			host: (data) => `${config.yetian.host}fenlei/${data.type}/1.html`,
			regExp: (html, source) => abc_classify(html, source, config.yetian.host),
		},
	},
	qianbi: {
		name: '铅笔小说网',
		host: 'https://www.x23qb.com',
		charset: 'gbk',
		search: () => [], // 懒得写
		// 分类
		classify: {
			host: (data) => `https://www.x23qb.com/${data.type}/${data.page}/`,
			regExp: (html, source) => qianbi_classify(html, source),
		},
		bookDetail: {
			host: (data) => `https://www.x23qb.com/book/${data.bookId}/`,
			regExp: (html, source) => qianbi_detail(html, source),
		},
		// 文本
		bookText: {
			host: (data) =>
				`https://www.x23qb.com/book/${data.bookId}/${data.chapterId}.html`,
			regExp: (html) => qianbi_bookText(html),
		},
	},
};

module.exports = config;
